﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Util
{
    public class Log
    {
        static List<String> errorList;
        static List<String> logList;
        static Boolean debugMode;

        static Log()
        {
            errorList = new List<string>();
            logList = new List<string>();

            // Turn this value false to turn off debug mode.
            debugMode = true;
        }

        /// <summary>
        /// Check whether webpage is in debug mode or not.
        /// </summary>
        public static Boolean DebugMode
        {
            get { return debugMode; }
        }

        /// <summary>
        /// Log new error to error list.
        /// </summary>
        /// <param name="error">Error description.</param>
        public static void LogError(String error)
        {
            errorList.Add(error);
            logList.Add("Error - " + error);
        }

        /// <summary>
        /// Write a log to keep tracking the function.
        /// </summary>
        /// <param name="log"></param>
        public static void LogInfo(String log)
        {
            logList.Add(log);
        }

        /// <summary>
        /// Current error list.
        /// </summary>
        public static List<String> ErrorList
        {
            get { return new List<string>(errorList); }
        }

        /// <summary>
        /// Current log list.
        /// </summary>
        public static List<String> LogList
        {
            get { return logList; }
        }

        /// <summary>
        /// Clear the lists for new debug session.
        /// </summary>
        public static void ClearSession()
        {
            errorList.Clear();
            logList.Clear();
        }

        /// <summary>
        /// Clear the error list.
        /// </summary>
        public static void ClearError()
        {
            errorList.Clear();
        }
    }
}